package com.cow.controller;

import com.cow.entity.ProductBrand;
import com.cow.service.ProductBrandService;
import com.cow.util.general.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/productBrand")
public class ProductBrandController {
    @Autowired
    private ProductBrandService productBrandService;

    @GetMapping("/findAllName")
    public CommonResult findAllName(){
        List<String> brandNames = productBrandService.list()
                .stream()
                .map(ProductBrand::getBrandName)
                .collect(Collectors.toList());
        return CommonResult.success("品牌名称查询成功",brandNames);
    }
}
